//package com.ibm.risk.irmp.common.auth.oauth2.welink;
//
//import org.springframework.http.HttpHeaders;
//import org.springframework.security.oauth2.client.userinfo.DefaultReactiveOAuth2UserService;
//import org.springframework.web.reactive.function.client.*;
//import reactor.core.publisher.Mono;
//
//import java.util.function.Consumer;
//
//public class WeLinkReactiveOAuth2UserService extends DefaultReactiveOAuth2UserService {
//
//    static class WeLinkExchangeFilterFunction implements ExchangeFilterFunction{
//        @Override
//        public Mono<ClientResponse> filter(ClientRequest request, ExchangeFunction next) {
//            String token = request.headers().getFirst(AUTH_COOKIE_NAME);
//            token = token.substring("Bearer ".length());
//            HttpHeaders headers = new HttpHeaders();
//            headers.addAll(request.headers());
//            headers.remove(AUTH_COOKIE_NAME);
//            headers.set("x-wlk-Authorization", token);
//            request =  ClientRequest.from(request).headers(new Consumer<HttpHeaders>() {
//                @Override
//                public void accept(HttpHeaders httpHeaders) {
//                    httpHeaders.clear();
//                    httpHeaders.addAll(headers);
//                }
//            }).build();
//            return next.exchange(request);
//        }
//    }
//    public WeLinkReactiveOAuth2UserService(){
//        setWebClient(WebClient.builder().filter(new WeLinkExchangeFilterFunction()).build());
//    }
//}
